package com.wjcxf.guonianla.animation;

import android.content.Context;
import android.view.View;
import android.view.animation.AnimationSet;
import android.widget.ImageView;

public class AnimationPacket {
    //是否阻塞
    private boolean isBlock = false;
    private String name;
    //持续时间(ms)
    private int duration = 0;
    private ImageView imageView;
    private AnimationSet animationSet;

    public AnimationPacket(int duration){
        this.duration = duration;
        this.isBlock = true;
    }

    public AnimationPacket(ImageView imageView, AnimationSet animationSet,int duration,boolean isBlock,String name) {
        this.imageView = imageView;
        this.animationSet = animationSet;
        this.animationSet.setDuration(duration);
        this.duration = duration;
        this.isBlock = isBlock;
        this.name = name;
    }

    public ImageView getImageView() {
        return imageView;
    }

    public void setImageView(ImageView imageView) {
        this.imageView = imageView;
    }

    public AnimationSet getAnimationSet() {
        return animationSet;
    }

    public void setAnimationSet(AnimationSet animationSet) {
        this.animationSet = animationSet;
    }

    public void playAnimation(Context context){
        imageView.clearAnimation();
        imageView.startAnimation(animationSet);
    }
    public void stopAnimation(){
        imageView.clearAnimation();
        imageView.setVisibility(View.INVISIBLE);
    }


    public int getDuration() {
        return duration;
    }

    public boolean isBlock() {
        return isBlock;
    }

    public String getName() {
        return name;
    }
}
